package com.chainyoung.component_tmperson.ui.activity.hdwallet;

import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chainyoung.common.appcommon.entity.HdWalletCache;
import com.chainyoung.common.base.BaseActivity;
import com.chainyoung.common.di.AppComponent;
import com.chainyoung.common.utils.SPUtil;
import com.chainyoung.component_tmperson.R;
import com.chainyoung.component_tmperson.R2;
import com.chainyoung.component_tmperson.di.component.DaggerPersonActivityComponent;
import com.chainyoung.component_tmperson.di.module.PersonActivityModule;
import com.chainyoung.component_tmperson.ui.adapter.LocalWalletListAdapter;
import com.chainyoung.component_tmperson.ui.adapter.LocalWalletListAdapter1;
import com.chainyoung.component_tmperson.ui.mvp.contract.SelectHdWalletListContract;
import com.chainyoung.component_tmperson.ui.mvp.presenter.SelectHdWalletListPresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.chainyoung.common.constant.LibConstant.WALLET_SAVE_TIME;

public class SelectHdWalletListActivity extends BaseActivity<SelectHdWalletListPresenter> implements SelectHdWalletListContract.View {



    @BindView(R2.id.rv_list)
    RecyclerView rvList;

    private List<HdWalletCache> hdwallets = new ArrayList<>();
    private LocalWalletListAdapter adapter;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerPersonActivityComponent.builder()
                .appComponent(appComponent)
                .personActivityModule(new PersonActivityModule(this))
                .build()
                .inject(this);
    }

    @Override
    protected void initUI() {
        setCurrentTitle("选择钱包");
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
        DividerItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL);
        itemDecoration.setDrawable(ContextCompat.getDrawable(mContext, R.drawable.shape_divider_gray_10));
        rvList.addItemDecoration(itemDecoration);
        adapter = new LocalWalletListAdapter(hdwallets);
        rvList.setLayoutManager(layoutManager);
        rvList.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        mPresenter.getAllHdWalletCaches(null);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.tmperson_select_hdwallet_activity;
    }

    @Override
    public void onGetAllHdWalletCaches(List<HdWalletCache> datas) {
        hdwallets.clear();
        if (datas != null) {
            hdwallets.addAll(datas);
        }
        adapter.notifyDataSetChanged();
    }


}
